package com.controller;

import antlr.collections.impl.LList;
import com.entity.Td_newstype;
import com.service.inte.NewsTypeServiceInte;
import com.service.inte.TeamServiceInte;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class TeamController {

    @Autowired
    private TeamServiceInte teamServiceInte;

    @Autowired
    private NewsTypeServiceInte newsTypeServiceInte;

    @GetMapping("getNewsType")
    public List<Td_newstype> getNewsType(int fatherTypeId, HttpServletResponse response, HttpServletRequest request){
        return newsTypeServiceInte.getAllByFD_FatherLevelID(fatherTypeId);
    }

    @PostMapping("getTeam")
    @ResponseBody
    public List<Object[]> getTeamDetail(int typeId, int page, HttpServletRequest request, HttpServletResponse response){
        return teamServiceInte.getTeamByFd_TypeId(typeId,page);
    }

    @PostMapping("getLunBo")
    @ResponseBody
    public List<Object[]> getLunBo(int typeId){
        return teamServiceInte.getLunBo(typeId);
    }

    @GetMapping("turnNews")
    public String turnNews(){
        return "news/politicalNews";
    }

    @GetMapping("turnDetail")
    public String turnDetail(int id,HttpServletRequest request){
        request.setAttribute("detail",teamServiceInte.getDetail(id));
        return "news/detail";
    }

    @GetMapping("turnPolicalType")
    public String turnPolicalType(){
        return "news/politicalType.html";
    }

    @GetMapping("getPolicalType")
    @ResponseBody
    public List<Object[]> getPolicalType(int type,int page){
        return teamServiceInte.getTypeByCreateTimeDesc(type,page);
    }
}
